home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Palettes / PAThumbWheel / PAThumbWheel.m < prev    next >
Text File  |  1995-06-12  |  6KB  |  131 lines

  1. #import "PAThumbWheel.h"
  2. #import "PAThumbWheelCell.h"
  3.  
  4. static id TWCellClass = nil;
  5.  
  6. /******************************************************************************
  7.     PAThumbWheelCell
  8.     
  9. PAThumbWheel offers the functionality of Slider plus the features that you would expect from a real thumbwheel (including 2 3/4 D Graphics!).
  10.  
  11. PAThumbWheel has a linear display mode and a radial display mode and offers the ability to assign a value to the visible region of the control as well as an absolute value that the ThumbWheel will either ignore, bound to or wrap around.
  12.  
  13. PAThumbWheel can also return relative values via its -relativeIntValue & -relativeFloatValue methods. A snap back option allows mouse loops to start from and return to a base value.
  14.  
  15. Copyright 1992, Jeff Martin. (jmartin@next.com 415-780-3833)
  16. ******************************************************************************/
  17.  
  18. @implementation PAThumbWheel
  19.  
  20. + setCellClass:factoryId
  21. {
  22.     TWCellClass = factoryId;
  23.     return self;
  24. }
  25.  
  26. - (BOOL)acceptsFirstMouse {return YES;}
  27.  
  28. - initFrame:(const NXRect *)f
  29. {
  30.   [super initFrame:f];
  31.   if(TWCellClass) [self setCell:[[TWCellClass alloc] init]];
  32.   else [self setCell:[[PAThumbWheelCell alloc] init]];
  33.   return self;
  34. }
  35.  
  36. // Direction: vertical or horizontal
  37. - (int)direction { return [cell direction]; }
  38. - setDirection:(int)dir { [cell setDirection:dir]; return self; }
  39. - takeDirectionFromMatrix:sender
  40. { [cell setDirection:[sender selectedTag]]; [self display]; return self; }
  41. - (BOOL)isVertical { return [(PAThumbWheel *)cell isVertical]; }
  42. - setVertical { [cell setVertical]; return self; }
  43. - (BOOL)isHorizontal { return [cell isHorizontal]; }
  44. - setHorizontal { [cell setHorizontal]; return self; }
  45.  
  46. // DisplayMode: radial or linear
  47. - (int)displayMode { return [cell displayMode]; }
  48. - setDisplayMode:(int)mode { [cell setDisplayMode:mode]; return self; }
  49. - takeDisplayModeFromMatrix:sender
  50. { [cell setDisplayMode:[sender selectedTag]]; [self display]; return self; }
  51. - toggleDisplayMode:sender
  52. { [cell setDisplayMode:![cell displayMode]]; [self display]; return self; }
  53. - (BOOL)isRadial { return [cell isRadial]; }
  54. - setRadial { [cell setRadial]; return self; }
  55. - (BOOL)isLinear { return [cell isLinear]; }
  56. - setLinear { [cell setLinear]; return self; }
  57.  
  58. // Visible min and max
  59. - (float)visibleMax { return [cell visibleMax]; }
  60. - setVisibleMax:(float)max { [cell setVisibleMax:max]; return self; }
  61. - takeVisibleMaxFrom:sender
  62. { [cell setVisibleMax:[sender floatValue]]; [self display]; return self; }
  63. - (float)visibleMin { return [cell visibleMin]; }
  64. - setVisibleMin:(float)min { [cell setVisibleMin:min]; return self; }
  65. - takeVisibleMinFrom:sender
  66. { [cell setVisibleMin:[sender floatValue]]; [self display]; return self; }
  67. - (float)visibleRange { return [cell visibleRange]; }
  68. - (float)middleValue { return [cell middleValue]; }
  69.  
  70. // Absolute mode: unbounded, bounded or wrapped
  71. - (int)absoluteMode { return [cell absoluteMode]; }
  72. - setAbsoluteMode:(int)mode { [cell setAbsoluteMode:mode]; return self; }
  73. - takeAbsoluteModeFromMatrix:sender
  74. { [cell setAbsoluteMode:[sender selectedTag]]; [self display]; return self; }
  75. - (BOOL)isUnbounded { return [cell isUnbounded]; }
  76. - setUnbounded { [cell setUnbounded]; return self; }
  77. - (BOOL)isBounded { return [cell isBounded]; }
  78. - setBounded { [cell setBounded]; return self; }
  79. - (BOOL)isWrapped { return [cell isWrapped]; }
  80. - setWrapped { [cell setWrapped]; return self; }
  81. - (float)absoluteMax { return [cell absoluteMax]; }
  82. - setAbsoluteMax:(float)value { [cell setAbsoluteMax:value]; return self; }
  83. - takeAbsoluteMaxFrom:sender
  84. { [cell setAbsoluteMax:[sender floatValue]]; [self display]; return self; }
  85. - (float)absoluteMin { return [cell absoluteMin]; }
  86. - setAbsoluteMin:(float)value { [cell setAbsoluteMin:value]; return self; }
  87. - takeAbsoluteMinFrom:sender
  88. { [cell setAbsoluteMin:[sender floatValue]]; [self display]; return self; }
  89. - (float)absoluteRange { return [cell absoluteRange]; }
  90.  
  91. // Relative Values
  92. - (int)relativeIntValue { return [cell relativeIntValue]; }
  93. - (float)relativeFloatValue { return [cell relativeFloatValue]; }
  94. - resetRelativeValue { [cell resetRelativeValue]; return self; }
  95.  
  96. // Snap back characteristic
  97. - (BOOL)snapsBack { return [cell snapsBack]; }
  98. - setSnapsBack:(BOOL)flag { [cell setSnapsBack:flag]; return self; }
  99. - takeSnapsBackFromSwitch:sender
  100. { [cell setSnapsBack:[sender state]]; [self display]; return self; }
  101. - (float)snapBackValue { return [cell snapBackValue]; }
  102. - setSnapBackValue:(float)val { [cell setSnapBackValue:val]; return self; }
  103. - takeSnapBackValueFrom:sender
  104. { [cell setSnapBackValue:[sender floatValue]]; [self display]; return self; }
  105.  
  106. // Dash interval (set in degrees or points depending on displayMode)
  107. - (float)dashInterval { return [cell dashInterval]; }
  108. - setDashInterval:(float)val { [cell setDashInterval:val]; return self; }
  109. - takeDashIntervalFrom:sender
  110. { [cell setDashInterval:[sender floatValue]]; [self display]; return self; }
  111.  
  112. // Showing the main dash
  113. - (BOOL)showMainDash { return [cell showMainDash]; }
  114. - setShowMainDash:(BOOL)flag { [cell setShowMainDash:flag]; return self; }
  115. - takeShowMainDashFromSwitch:sender
  116. { [cell setShowMainDash:[sender state]]; [self display]; return self; }
  117.  
  118. // Color of the ThumbWheel
  119. - (NXColor)color { return [cell color]; }
  120. - setColor:(NXColor)color { [cell setColor:color]; return self; }
  121. - takeColorFrom:sender { [self setColor:[sender color]]; return self; }
  122.  
  123. // tag and disabled
  124. - takeTagFrom:sender { [self setTag:[sender intValue]]; return self; }
  125. - takeDisabledFromSwitch:sender
  126. { [self setEnabled:![sender state]]; [self display]; return self; }
  127.  
  128. - (const char *)getInspectorClassName { return "PAThumbWheelInspector"; }
  129.  
  130. @end
  131.